@extends('Admin.Layout.main')
@section('privateheader')
<!-- DataTables -->
<link rel="stylesheet" href="{{__BASE__}}admin/plugins/datatables/dataTables.bootstrap.css">
<link rel="stylesheet" href="{{__BASE__}}admin/plugins/treetable/css/jquery.treeTable.css">
@endsection
@section('content')
<!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    @if($data['flag'] == 3)
                        <h3 class="box-title">地区列表管理</h3>
                        <a class="btn bg-olive" href="{{__BASE__}}admini/area/create">添加地区</a>
                        <a class="btn bg-red" href="{{__BASE__}}admini/area/rb">回收站</a>
                    @elseif($data['flag'] == 4)
                        <h3 class="box-title">网站栏目管理回收站</h3>
                        <a class="btn bg-olive" href="{{__BASE__}}admini/area">网站栏目管理</a>
                    @endif
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <table class="table table-bordered table-striped" id="treeTable2">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>地区名称</th>
                            <th>地区简称</th>
                            <th>地区全称</th>
                            <th>省市区县</th>
                            <th>拼音</th>
                            <th>长途区号</th>
                            <th>邮编</th>
                            <th>首字母</th>
                            <th>经度</th>
                            <th>纬度</th>
                            <th>创建时间</th>
                            <th>修改时间</th>
                            <th>操作人</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @if(!empty($data['list']))
                            @foreach($data['list'] as $v)
                                <tr id="{{$v['id']}}" <?php echo $v['pid'] != '' ? 'pId="'.$v['pid'].'"' : '';?> >
                                    <th>{{$v['id']}}</th>
                                    <td>&nbsp;&nbsp;{{$v['name'] or ''}}</td>
                                    <td>{{$v['shortname'] or ''}}</td>
                                    <td>{{$v['merger_name'] or ''}}</td>
                                    <td>
                                        <?php
                                            switch($v['level'])
                                            {
                                                case 1:
                                                    echo '省';
                                                    break;
                                                case 2:
                                                    echo '市';
                                                    break;
                                                case 3:
                                                    echo '区';
                                                    break;
                                                
                                            }
                                        ?>
                                    </td>
                                    <td>{{$v['pinyin'] or ''}}</td>
                                    <td>{{$v['code'] or ''}}</td>
                                    <td>{{$v['zip_code'] or ''}}</td>
                                    <td>{{$v['first'] or ''}}</td>
                                    <td>{{$v['lng'] or ''}}</td>
                                    <td>{{$v['lat'] or ''}}</td>
                                    <td><?php echo !empty($v['create_time']) ? date('Y-m-d H:i:s',$v['create_time']) : '';?></td>
                                    <td><?php echo !empty($v['update_time']) ? date('Y-m-d H:i:s',$v['update_time']) :''; ?></td>
                                    <td>{{$v['username']}}</td>
                                    <td>
                                        @if($data['flag'] == 3)
                                            <button class="btn bg-olive" type="button" onclick="javascript:location.href='/admini/area/create?pid={{$v['id'] or 0}}'">添加</button>
                                            <button class="btn bg-orange" type="button" onclick="javascript:location.href='/admini/area/{{$v['id'] or ''}}/edit'">修改</button>
                                            <button class="btn bg-red delbutton" type="button" delurl="/admini/area/{{$v['id'] or ''}}" skipurl="/admini/area" ac="1">删除</button>
                                        @elseif($data['flag'] == 4)
                                            <button class="btn bg-orange delbutton" type="button" delurl="/admini/area/{{$v['id'] or ''}}" skipurl="/admini/area" ac="3">还原</button>
                                            <button class="btn bg-red delbutton" type="button" delurl="/admini/area/{{$v['id'] or ''}}" skipurl="/admini/area" ac="2">删除</button>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                        @endif
                        </tbody>
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->
</section>
@endsection
@section('privatefooter')
<script src="{{__BASE__}}/admin/plugins/treetable/js/jquery.treeTable.js" type="text/javascript"></script>
<!-- /.content -->
<script type="text/javascript">
    $(function(){
        @if($data['flag'] != 4)
            var option = {
                theme:'vsStyle',
                expandLevel : 2
            };
            option.theme = 'default';
            $('#treeTable2').treeTable(option);
        @endif
    });
</script>
@endsection